#include "LevelState.h"
#include "HighScoresState.h"


CLevelState* CLevelState::GetInstance(void)
{
	static CLevelState s_Instance;
	return &s_Instance;
}

CLevelState::CLevelState(void)
{
}

CLevelState::~CLevelState(void)
{
}

void CLevelState::Enter(void)
{
	vCollision.clear();
	vTiles.clear();
	vEvents.clear();

	m_pOM = CObjectManager::GetInstance();

	test = new CTileManager();

	test->LoadTile(vTiles, vCollision, vEvents, "../resources/XML/overAllTileMap_Level3.xml");
	for(int i = 0; i < (int)vCollision.size(); i++)
		m_pOM->AddObject(&vCollision[i]);


	//for(int i = 0; i < (int)vEvents.size(); i++)
	//	m_pOM->AddObject(&vEvents[i]);
//	if (level1 == true)
//	{
//	test->LoadTile(vTiles, vCollision, vEvents, "../resources/XML/overAllTileMap_Level1.xml");
///*	for(int i = 0; i < (int)vTiles.size(); i++)
//		m_pOM->AddObject(&vTiles[i]);*/
//	for(int i = 0; i < (int)vCollision.size(); i++)
//		m_pOM->AddObject(&vCollision[i]);
//	//for(int i = 0; i < (int)vEvents.size(); i++)
//	//	m_pOM->AddObject(&vEvents[i]);
//	}
//	if (level2 == true)
//	{
//	test->LoadTile(vTiles, vCollision, vEvents, "../resources/XML/overAllTileMap_Level2.xml");
//	for(int i = 0; i < (int)vCollision.size(); i++)
//		m_pOM->AddObject(&vCollision[i]);
//	}

	CHighScoresState::GetInstance()->SetHighScore(150000);

}

void CLevelState::Exit(void)
{
	delete test;
}

bool CLevelState::Input(void)
{
	return true;
}

void CLevelState::Update(float fElapsedTime)
{
	int hs = CHighScoresState::GetInstance()->GetHighScore();
	CHighScoresState::GetInstance()->SetHighScore(int( hs - fElapsedTime ));
}

void CLevelState::Render(void)
{
	test->Render(vTiles);
}